package com.starsoft.trade.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.starsoft.frame.core.orm.BaseDao;
import com.starsoft.trade.bean.TradeFee;
@Repository
public class TradeFeeDao extends BaseDao<TradeFee, Integer> {
	
	public TradeFee getFee(Integer acountId, String tradeType, String exchange){
		Map<String, Object> params = new HashMap<>();
		params.put("acountId", acountId);
		params.put("tradeType", tradeType);
		params.put("exchange", exchange);
		List<TradeFee> fee = this.findByMap(params);
		if(fee.isEmpty()){
			return null;
		} else {
			return fee.get(0);
		}
	}
	
	public List<TradeFee> getFee(Integer acountId){
		Map<String, Object> params = new HashMap<>();
		params.put("acountId", acountId);
		return this.findByMap(params);
	}
	
	public void deleteAll(Integer acountId){
		String hql = "delete from TradeFee where acountId=?0";
		this.update(hql, acountId);
	}
	
}
